#pragma once

#include "bevdet_tensortrt/bevdet.h"
#include "muduo/net/EventLoop.h"
#include "muduo/net/EventLoopThread.h"
#include <cassert>
#include <chrono>
#include <cstdio>
#include <fstream>
#include <functional>
#include <interface/msg/images.hpp>
#include <iostream>
#include <rclcpp/rclcpp.hpp>
#include <string>
#include <thread>
#include <utils/bevdetConfig.h>
#include <yaml-cpp/yaml.h>
using std::chrono::duration;
using std::chrono::high_resolution_clock;

namespace camera_perception {

class CameraPerception {

protected:
    using onBevDetCallback = std::function<void(std::vector<Box>)>;

public:
    CameraPerception(void);
    ~CameraPerception(void);

private:
    void getInfo();
    bool fileExists(const std::string& filePath);
    void getExecutionPath(void);
    void sample(YAML::Node& config);

    void mockObjects();

public:
    void setImages(std::shared_ptr<interface::msg::Images> images);
    void setBevDetCallback(const onBevDetCallback& cb);
    void setBevDetMockCallback(const onBevDetCallback& cb);

private:
    rclcpp::Logger logger_;
    std::shared_ptr<BEVDet> bevDetPtrs_ = nullptr;
    muduo::net::EventLoopThread mockObjectThread_;
    std::string configPath_;
    size_t imgN_;
    int imgW_;
    int imgH_;
    std::string modelConfig_;
    std::string imgstageFile_;
    std::string bevstageFile_;
    YAML::Node camconfig_;
    YAML::Node sample_;
    camsData sampleData_;
    onBevDetCallback cb_;
    onBevDetCallback mockcb_;
    bool isMock_ = false;
};
}